home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Examples / DemoText / UTEDocument.p < prev   
Encoding:
Text File  |  1990-10-25  |  6.2 KB  |  231 lines  |  [TEXT/MPS ]

  1. {[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]}
  2.  
  3. { UTEDocument.p }
  4. { Copyright © 1990 by Apple Computer, Inc. All rights reserved. }
  5.  
  6. {
  7.     This separate unit for TE Documents is still an example and not a supported Building Block.
  8.     It provides a backing document for those times when you want to write your TEView to external
  9.     media.  Remember, since its not a building block right now the structure is subject to more
  10.     than the usual amount of change.  Let us know what you think.
  11. }
  12.  
  13. UNIT UTEDocument;
  14.  
  15.     INTERFACE
  16.  
  17.         USES
  18.             { • MacApp }
  19.             UMacApp,
  20.  
  21.             { • Building Blocks }
  22.             UPrinting, UTEView,
  23.  
  24.             { • Required for this unit's interface }
  25.  
  26.             { • Implementation use }
  27.             ToolUtils, Fonts, Resources, Script, Picker;
  28.  
  29.         CONST
  30.  
  31.             kTextFileType        = 'TEXT';                { Standard file-type code for saved disk
  32.                                                          files -- uses standard text files }
  33.             kWindowRsrcID        = 1004;                 { 'view' template for a DemoText window }
  34.             kViewRsrcID         = 1005;                 { 'view' template for a DemoText view }
  35.  
  36.             { Menu numbers }
  37.             mFont                = 10;
  38.  
  39.             { Command numbers }
  40.  
  41.             cWidthSuperView         = 601;                { View-width-determination commands }
  42.             cWidthView            = 602;
  43.             cWidthOnePage        = 603;
  44.  
  45.             cHeightSuperView        = 604;                { View-height-determination commands }
  46.             cHeightPages        = 605;
  47.             cHeightText         = 606;
  48.             cHeightConst        = 607;
  49.  
  50.             cJustForceLeft            = 608;                    { Justification commands }
  51.             cJustCenter         = 609;
  52.             cJustRight            = 610;
  53.             cJustSystem            = 611;
  54.  
  55.             { Command numbering scheme:
  56.                 styles    = 1000
  57.                 sizes    = 1100
  58.                 just    = 1200
  59.                 fonts    = 1300
  60.                 hiers    = 1400
  61.                 colors    = 1500
  62.             }
  63.  
  64.             { Command numbers for typestyle attributes }
  65.             cPlainText            = 1001;
  66.             cBold                = 1002;
  67.             cItalic             = 1003;
  68.             cUnderline            = 1004;
  69.             cOutline            = 1005;
  70.             cShadow             = 1006;
  71.             cCondense            = 1007;
  72.             cExtend             = 1008;
  73.  
  74.             { Command numbers for font-size commands }
  75.             cSizeChange         = 1100;
  76.             cSizeBase            = 1100;
  77.             cSizeMin            = 1109;
  78.             cSizeMax            = 1124;
  79.             { 1101-1197 reserved for font sizes 1-97 pts. }
  80.             cSizeGrow            = 1198;
  81.             cSizeShrink         = 1199;
  82.  
  83.             { Command numbers to cover other stylistic changes }
  84.             cJustChange         = 1200;
  85.             cFontChange         = 1300;
  86.  
  87.             { Command numbers for the hierarchial menu }
  88.             cStyle                = 1401;
  89.             cSize                = 1402;
  90.             cFont                = 1403;
  91.             cColor                = 1404;
  92.  
  93.             { Command numbers for changing colors }
  94.             cColorChange        = 1500;
  95.             cColorText            = 1501;
  96.             cColorBackground    = 1502;
  97.  
  98.             { Constant for staggering windows }
  99.             kStaggerAmount        = 16;
  100.  
  101.             { Constant for amount to relative size text selection }
  102.             kRelSizeAmount        = 4;
  103.  
  104.             { Constants for the text specs resource }
  105.             kTextSpecsRsrcType    = 'SPEC';
  106.             kTextSpecsRsrcID    = 1;
  107.  
  108.             { Constants for the text style resource }
  109.             kTextStyleRsrcType    = 'STYL';
  110.             kStylesRsrcID        = 1;
  111.             kElementsRsrcID     = 2;
  112.  
  113.             { Constants for the print info resource }
  114.             kPrintInfoRsrcType    = 'PRNT';
  115.             kPrintInfoRsrcID    = 1;
  116.  
  117.             { Constants for the prompts string list }
  118.             kPromptsRsrcID        = 1005;
  119.             kColTextPrompt        = 1;
  120.             kColBackPrompt        = 2;
  121.  
  122.             { The 'File is too large' alert }
  123.             kFileTooBig         = 1000;
  124.  
  125.             kHierDisplayedMBar    = 131;                    { Displayed menus on hier. menu system }
  126.             kNonHierDisplayedMBar = 128;                { Displayed menus on non-hier. system }
  127.  
  128.             kHierMenuOffset     = 1000;                 { Offset added to non-hier menu cmds to get
  129.                                                          the right number }
  130.  
  131.         TYPE
  132.  
  133.             TextSpecs            =                        { Additional document specifications }
  134.                 RECORD
  135.                 theTextFont:        Str255;
  136.                 theTextFace:        Style;
  137.                 theTextSize:        INTEGER;
  138.                 theTextColor:        RGBColor;
  139.                 theJustification:    INTEGER;            { record justification }
  140.                 theBackColor:        RGBColor;            { Window's background color }
  141.                 END;
  142.             TextSpecsPtr        = ^TextSpecs;
  143.             TextSpecsHdl        = ^TextSpecsPtr;
  144.  
  145.             TTEDocument        = OBJECT (TDocument)
  146.  
  147.                 fDocText:            Handle;             { The text owned by the document }
  148.                 fStyles:            TEStyleHandle;        { Style handle, if any }
  149.                 fElements:            STHandle;            { Handle to element array, if any }
  150.                 fTEView:            TTEView;            { The view which displays the text }
  151.                 fTextSpecs:         TextSpecs;            { Specifies properties of the text }
  152.  
  153.                                 { Initialization and freeing }
  154.  
  155.                 PROCEDURE TTEDocument.ITEDocument(itsFileType, itsCreator: OSType;
  156.                                                     usesDataFork, usesRsrcFork: BOOLEAN;
  157.                                                     keepsDataOpen, keepsRsrcOpen: BOOLEAN);
  158.                 { Initialization method for TDocument. }
  159.                 PROCEDURE TTEDocument.Free; OVERRIDE;
  160.                 PROCEDURE TTEDocument.DoInitialState; OVERRIDE;
  161.                 PROCEDURE TTEDocument.FreeData; OVERRIDE;
  162.  
  163.                 { Filing }
  164.  
  165.                 PROCEDURE TTEDocument.DoNeedDiskSpace(VAR dataForkBytes,
  166.                     rsrcForkBytes: LONGINT); OVERRIDE;
  167.                 PROCEDURE TTEDocument.DoRead(aRefNum: INTEGER;
  168.                                                rsrcExists, forPrinting: BOOLEAN); OVERRIDE;
  169.                 PROCEDURE TTEDocument.DoWrite(aRefNum: INTEGER;
  170.                                                 makingCopy: BOOLEAN); OVERRIDE;
  171.  
  172.                 { Making views and windows }
  173.  
  174.                 PROCEDURE TTEDocument.DoMakeViews(forPrinting: BOOLEAN); OVERRIDE;
  175.  
  176.                 { Command processing }
  177.  
  178.                 FUNCTION TTEDocument.DoMenuCommand(aCmdNumber: CmdNumber): TCommand; OVERRIDE;
  179.                 PROCEDURE TTEDocument.DoSetupMenus; OVERRIDE;
  180.  
  181.                 { Auxiliary routines }
  182.  
  183.                 PROCEDURE TTEDocument.ChangeBackColor(newColor: RGBColor);
  184.  
  185.                 PROCEDURE TTEDocument.SetSpecStyle;
  186.  
  187.                 PROCEDURE TTEDocument.ShowReverted; OVERRIDE;
  188.                 { When the user reverts a document, this is called after reading
  189.                   the old document and before displaying it. Causes the reverted
  190.                   font specs to be installed. }
  191.  
  192.                 { Inspecting }
  193.  
  194.                 PROCEDURE TTEDocument.Fields(PROCEDURE
  195.                                                DoToField(fieldName: Str255;
  196.                                                          fieldAddr: Ptr;
  197.                                                          fieldType: INTEGER)); OVERRIDE;
  198.  
  199.                 END;
  200.  
  201.             TJustCommand        = OBJECT (TCommand)
  202.                 fTEView:            TTEView;
  203.                 fOldJust:            INTEGER;
  204.                 fNewJust:            INTEGER;
  205.  
  206.                 PROCEDURE TJustCommand.IJustCommand(itsTEView: TTEView;
  207.                                                     itsNewJust: INTEGER);
  208.  
  209.                 PROCEDURE TJustCommand.DoIt; OVERRIDE;
  210.  
  211.                 PROCEDURE TJustCommand.RedoIt; OVERRIDE;
  212.  
  213.                 PROCEDURE TJustCommand.UndoIt; OVERRIDE;
  214.  
  215.                 PROCEDURE TJustCommand.Fields(PROCEDURE
  216.                                               DoToField(fieldName: Str255;
  217.                                                         fieldAddr: Ptr;
  218.                                                         fieldType: INTEGER)); OVERRIDE;
  219.  
  220.                 END;
  221.  
  222.         VAR
  223.             gDefaultSpecs:        TextSpecs;                { Text specs as default for new documents }
  224.             gStaggerCount:        INTEGER;
  225.  
  226.     IMPLEMENTATION
  227.  
  228.         {$I UTEDocument.inc1.p}
  229.  
  230. END.
  231.